/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cifar10;

import java.awt.image.BufferedImage;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import javax.imageio.ImageIO;

/**
 *
 * @author andreas
 */
public class AvgColTest {

    static String baseDir = "/home/andreas/cifar10/";
    
    static public void main(String[] args) throws FileNotFoundException, IOException {
        //List<String> labels=getLabels();
        BufferedWriter writer = new BufferedWriter(new FileWriter(baseDir + "featurefiles/avgcolTest"));
        for (int i = 1; i <= 300000; i++) {
            File f = new File(baseDir + "test/" + i + ".png");
            System.out.println(f.getName().split("\\.")[0]);
            BufferedImage img = ImageIO.read(f);
            long alpha = 0;
            long red = 0;
            long blue = 0;
            long green = 0;
            for (int y = 0; y < img.getHeight(); y++) {
                for (int x = 0; x < img.getWidth(); x++) {
                    int rgb = img.getRGB(x, y);
                    alpha += rgb >> 24 & 0xff;
                    red += rgb >> 16 & 0xff;
                    green += rgb >> 8 & 0xff;
                    blue += rgb & 0xff;
                }
            }
            writer.write(f.getName().split("\\.")[0] + "," + alpha + "," + red + "," + green + "," + blue + "\n");
        }
        writer.close();
    }
}
